package com.echat.core.generator.action.config;

import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

/**
 * 默认的代码生成的配置
 *
 * @author fengshuonan
 * @date 2017-10-28-下午8:27
 */
public class GunsGeneratorConfig extends AbstractGeneratorConfig {


    //包名配置
    final static String PRO_PACKAGE_NAME = "com.hd.sup";
    final static String PACKAGE_NAME = "com.hd.sup.modules.dashboard";
    final static String BIZ_NAME = "dashboard";
    final static String TABLE_PREFIX = "sp_";
    final static String OUT_PATH = "/Users/scylla/IdeaProjects/nutschan/generator";

    //数据库配置
    public static final String JDBC_DRIVER_NAME = "org.postgresql.Driver";
    public static final String DB_USER = "postgres";
    public static final String DB_PASSWORD = "123456";
    public static final String DB_URL = "jdbc:postgresql://172.16.22.170:65432/traffic_supervise";



    protected void globalConfig() {

        globalConfig.setOutputDir(OUT_PATH);//写自己项目的绝对路径,注意具体到java目录
        globalConfig.setFileOverride(true);
        globalConfig.setEnableCache(false);
        globalConfig.setBaseResultMap(true);
        globalConfig.setBaseColumnList(true);
        globalConfig.setOpen(false);
        globalConfig.setAuthor("chentl");
    }

    protected void dataSourceConfig() {
        dataSourceConfig.setDbType(DbType.POSTGRE_SQL);
        dataSourceConfig.setDriverName(JDBC_DRIVER_NAME);
        dataSourceConfig.setUsername(DB_USER);
        dataSourceConfig.setPassword(DB_PASSWORD);
        dataSourceConfig.setUrl(DB_URL);
    }

    protected void strategyConfig() {
        // 此处可以修改为您的表前缀
        strategyConfig.setTablePrefix(TABLE_PREFIX);
        strategyConfig.setNaming(NamingStrategy.underline_to_camel);
    }

    protected void packageConfig() {
        packageConfig.setParent(null);
        packageConfig.setEntity(PACKAGE_NAME + ".model");
        packageConfig.setMapper(PACKAGE_NAME + ".dao");
        packageConfig.setXml(PACKAGE_NAME + ".dao.mapping");
    }

    protected void contextConfig() {
        contextConfig.setProPackage(PRO_PACKAGE_NAME);
        contextConfig.setCoreBasePackage("com.ztyt.core");
        contextConfig.setBizChName("逆向工程类");
        contextConfig.setBizEnName(BIZ_NAME);
        contextConfig.setModuleName(BIZ_NAME);
        contextConfig.setProjectPath(OUT_PATH);//写自己项目的绝对路径
        contextConfig.setEntityName(BIZ_NAME);
        sqlConfig.setParentMenuName(null);//这里写已有菜单的名称,当做父节点

        /**
         * mybatis-plus 生成器开关
         */
        contextConfig.setEntitySwitch(true);
        contextConfig.setDaoSwitch(true);
        contextConfig.setServiceSwitch(true);

        /**
         * guns 生成器开关
         */
        contextConfig.setControllerSwitch(true);
        contextConfig.setIndexPageSwitch(true);
        contextConfig.setAddPageSwitch(true);
        contextConfig.setEditPageSwitch(true);
        contextConfig.setDetailPageSwitch(true);
        contextConfig.setJsSwitch(true);
        contextConfig.setInfoJsSwitch(true);
        contextConfig.setSqlSwitch(true);
    }

    @Override
    protected void config() {
        globalConfig();
        dataSourceConfig();
        strategyConfig();
        packageConfig();
        contextConfig();
    }
}
